//
//  HJBuyCell.m
//  Sneakers
//
//  Created by 胡光健 on 2017/10/27.
//  Copyright © 2017年 mac. All rights reserved.
//

#import "HJBuyCell.h"
#import "HJMineModel.h"
@interface HJBuyCell ()
@property (weak, nonatomic) IBOutlet UIImageView *mainImage;
@property (weak, nonatomic) IBOutlet UILabel *shoesName;
@property (weak, nonatomic) IBOutlet UILabel *code;
@property (weak, nonatomic) IBOutlet UILabel *money;
@property (weak, nonatomic) IBOutlet UILabel *stauteTime;
@property (weak, nonatomic) IBOutlet UIImageView *prencentImage;
@property (weak, nonatomic) IBOutlet UILabel *prencent;

@property (weak, nonatomic) IBOutlet UIButton *pay;

@end
@implementation HJBuyCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
    self.pay.layer.borderWidth = 0.5;
    self.pay.layer.borderColor = HJColorRGB(51).CGColor;
    self.pay.layer.cornerRadius = 16;
    self.pay.layer.masksToBounds = YES;
    
    self.stauteTime.font =HJFontSize(mScreenWidth/414 * 13);
    self.code.font =HJFontSize(mScreenWidth/414 * 13);
    self.shoesName.font =HJFontSize(mScreenWidth/414 * 15);
    self.prencent.font =HJFontSize(mScreenWidth/414 * 15);
    self.money.font =HJFontSize(mScreenWidth/414 * 19);
}

-(void)setBuyModel:(HJSellModel *)buyModel {
    _buyModel = buyModel;
    [self.mainImage sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@/%@",buyModel.avatar_base_url,buyModel.avatar_path]]];
    self.shoesName.text = buyModel.shoes_name;
    self.code.text = [NSString stringWithFormat:@"%@码",buyModel.shoes_size];
    self.money.text = [NSString stringWithFormat:@"￥%@",buyModel.sell_money];
    
    if ([buyModel.is_false isEqual:@1] || [buyModel.is_false isEqual:@2]) {
        self.stauteTime.text = [NSString stringWithFormat:@"预计到货：%@",buyModel.created_at];
    }else if ([buyModel.is_false isEqual:@3]) {
        self.stauteTime.text = [NSString stringWithFormat:@"已完成：%@",buyModel.created_at];
    }else {
        self.stauteTime.text = buyModel.created_at;
    }
   
    if ([buyModel.state2 isEqual:@0]) {
        self.prencent.textColor = HJColor(255, 72, 74);
        self.prencentImage.image = HJImage(@"Fill 7");
    }else {
        self.prencent.textColor = HJColor(71, 201, 157);
        self.prencentImage.image = HJImage(@"Fill 1 Copy 00");
    }
    
    if ([buyModel.percent isEqualToString:@"0.00"]) {
        self.prencent.text = @"";
        self.prencentImage.hidden = YES;
    }else {
        self.prencent.text = [NSString stringWithFormat:@"%@%%",buyModel.percent];
    }
    if ([buyModel.is_false isEqual:@2] && ![buyModel.express isEqualToString:@""]) {
        self.btmH.constant = 60.0;
    }else {
        self.btmH.constant = 0.0;
        self.pay.hidden = YES;
    }
    
    
}
- (IBAction)payBtn:(UIButton *)sender {
    NSString * imageStr = [NSString stringWithFormat:@"%@/%@",_buyModel.avatar_base_url,_buyModel.avatar_path];
    NSDictionary * dic = @{@"shoes_name":_buyModel.shoes_name,@"shoes_size":_buyModel.shoes_size,@"shoes_money":_buyModel.sell_money,@"shoes_image":imageStr,@"express":_buyModel.express};
    [mNotificationCenter postNotificationName:@"logisticsNotification" object:nil userInfo:dic];
}

@end
